<?php
ob_start();
try{
$wgExtensionCredits['parserhook'][] = array(
        'path' => __FILE__,     // Magic so that svn revision number can be shown
        'name' => "Example Extension",
        'description' => "A simple example parser function extension",    // Should be using descriptionmsg instead so that i18n is supported (but this is a simple example).
        'version' => 1, 
        'author' => "Me",
        'url' => "http://localhost/mediawiki-1.17.0/index.php?title=Manual:Parser_functions",
);
 
# Define a setup function
$wgHooks['ParserFirstCallInit'][] = 'efExampleParserFunction_Setup';
# Add a hook to initialise the magic word
$wgHooks['LanguageGetMagic'][]       = 'efExampleParserFunction_Magic';
ob_end_clean();
}catch(Exception $e){}
 
function efExampleParserFunction_Setup( &$parser ) {
        # Set a function hook associating the "applet" magic word with our function
 $parser->setFunctionHook( 'applet', 'efExampleParserFunction_Render' );
        return true;
}
 
function efExampleParserFunction_Magic( &$magicWords, $langCode ) {
        # Add the magic word
        # The first array element is whether to be case sensitive, in this case (0) it is not case sensitive, 1 would be sensitive
        # All remaining elements are synonyms for our parser function
        $magicWords['applet'] = array( 0,'applet' );
        # unless we return true, other parser functions extensions won't get loaded.
        return true;
}
 
function efExampleParserFunction_Render( $parser, $width=650, $height = 500, $archive='HanziDict.jar', $code='hanzidict.HanziDict.class' ) {
        # The parser function itself
        # The input parameters are wikitext with templates expanded
        # The output should be wikitext too
        //$output = "param1 is $param1 and param2 is $param2";
	$width = ($width>0?$width:650);
	$height = ($height>0?$height:500);
		$output = "<applet width='".$width."' height='".$height."' archive='".$archive."' code='".$code."' codebase='/mediawiki-1.17.0/extensions/JavaAppletParser'>
				<div style='width:".$width."px;height:".$height."px; text-align:center;'>
				YOUR BROWSER NOT SUPPORT JAVA <br />
				please <a href='http://www.java.com/en/download/' style='color:blue;text-decoration:underline'>click here to download java</a>
				</div>
			</applet>";

        return array( $output, 'noparse' => true, 'isHTML' => true );
}
